<?php
require_once '../../classes/includeAll_Layer2.php';


$deviceID  = filter_input(INPUT_POST,"deviceID");
$flags = json_decode(filter_input(INPUT_POST,"flags"));

if($flags == null || $flags == false || $deviceID == null || $deviceID == false || !$isAdmin)
{
  echo "false1";
  exit();
}
require '../../resources/getConnection.php';
$device = new Device($deviceID, $connection);
$flag = $device->ChangeFlag;

$flagMeaning = (new allFlags())->DeviceFlags;

  foreach ($flagMeaning as $key => $value) {
    if(in_array($key, $flags))
    {
        $flag &= ~$value;
    }  
  }
            
if($device->UpdateDevice(array("changeFlag"), array($flag)))
  echo "true";
else
  echo "false";